The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
5

anyway to include in config file

asked Mar 10 '13

updated Mar 10 '13

I am currently managing about 8 computers here and there, all using i3... and I have set of shared files and folders for stuff it can be reused in all (bash_aliases, bashrc, .vim, etc). In bash, specifically, is very convenient to use a dot to "include" other files within the executing script... I was wondering if we have (or could have) anything similar in i3 config file?

The main reason being, every time I change something in the config (happens quite often when I discover new things, or want certain windows to behave different from the default), and I have to update all files, over and over...

Any ideas?

Comments

I realize you have an answer, but I'd like to suggest what I do, it works great. I sync common dot files via a github repo[1] and a cron job. The fact that they are versioned is also attractive. [1]: https://github.com/wesleywerner/dotfiles

Wesley gravatar imageWesley (May 24 '13)edit

I would really like to advocate for adding including of files to i3. Something like being able to have a config.d directory, with small files instead of having this giant blob of text that is hard to share. Unfortunately, my skills with C is not enough to make this happen on my own :-(

gustavnikolaj gravatar imagegustavnikolaj (Mar 11 '14)edit

2 answers

Sort by » oldest newest most voted
1

answered Mar 11 '13

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

There is no include mechanism in i3 itself. But you can create the config file everytime X starts from templates.

#!/bin/bash
cat $HOME/.config/i3/config.base \
    $HOME/.config/i3/config.local > $HOME/.config/i3/config
exec /usr/bin/i3

Something like this as a wrapper-script around i3 should work.

Comments

Yeah, that sounds like the only option at this moment. Thanks!

bruno.braga gravatar imagebruno.braga (Mar 11 '13)edit
0

answered May 21 '13

marc gravatar image

I have the same problem. An include function would be very nice. Another option would be if/else conditons based on environment variables like $HOSTNAME etc. Creating the config on startup is an option but forces me to recreate the config file every time I made changes and want to reload the config on the fly.

Comments

If you often reload the config file, just make your keybinding call the script + reload, or — if you reload from the commandline — create an alias which calls the script + i3-msg reload.

Michael gravatar imageMichael (May 22 '13)edit

yes - that works - thanks!

marc gravatar imagemarc (May 23 '13)edit

Question Tools

2 followers

Stats

Asked: Mar 10 '13

Seen: 2,665 times

Last updated: Aug 17 '14